package ms.unicorn.modellanguage;

import ms.unicorn.diagram.providers.UnicornElementTypes;
import ms.unicorn.language.languagedef.ElementDefUtil;
import ms.unicorn.language.languagedef.EntityDef;

import org.eclipse.gmf.runtime.emf.type.core.IElementType;

public class LanguageEntity extends LanguageElement {

	private LanguageEntityEditHeperAdvice advice;

	public LanguageEntity(IModelLanguage language, EntityDef definition) {
		super(language, definition);
	}
	
	@Override
	public EntityDef getDefinition() {
		// TODO Auto-generated method stub
		return (EntityDef) super.getDefinition();
	}
		
	@Override
	protected IElementType getBaseType() {
		return UnicornElementTypes.Entity_2001;
	}
	
	public boolean acceptChild(LanguageElement element) {
		return getEditHelperAdvice().acceptChildren(element);
	}
	
	public void setEditHelperAdvice(IElementEditHelperAdvice advice) {
		this.advice = (LanguageEntityEditHeperAdvice)
			(advice instanceof LanguageEntityEditHeperAdvice ? advice : null);
	}

	@Override
	public LanguageEntityEditHeperAdvice getEditHelperAdvice() {
		return advice != null ? advice : LanguageEntityEditHeperAdvice.DefaultInstance;
	}

	public boolean isResizeable() {
		return ElementDefUtil.isResizeableFigure(getDefinition());
	}
}
